﻿using System;

namespace Panda.UI.Runtime
{
    public interface ILayer
    {
        public IRouter Router { get; set; }
        public bool IsAnimComplete { get; }
        public IPage CurrentPage { get; }
        
        public abstract void Register(string pageId, IPage page);
        
        /// <summary>
        /// 关闭所有页面，打开到应用内的某个页面
        /// </summary>
        /// <param name="pageId"></param>
        /// <param name="data"></param>
        /// <param name="success"></param>
        /// <param name="fail"></param>
        /// <param name="complete"></param>
        public abstract void ReLaunch(string pageId, object data, Action success, Action fail, Action complete);
        
        /// <summary>
        /// 关闭当前页面，跳转到应用内的某个页面
        /// </summary>
        /// <param name="pageId"></param>
        /// <param name="data"></param>
        /// <param name="success"></param>
        /// <param name="fail"></param>
        /// <param name="complete"></param>
        public abstract void RedirectTo(string pageId, object data, Action success, Action fail, Action complete);

        /// <summary>
        /// 保留当前页面，跳转到应用内的某个页面
        /// </summary>
        /// <param name="pageId"></param>
        /// <param name="data"></param>
        /// <param name="success"></param>
        /// <param name="fail"></param>
        /// <param name="complete"></param>
        /// <param name="createNewIfInHistory"></param>
        public abstract void NavigateTo(string pageId, object data, Action success, Action fail, Action complete, bool createNewIfInHistory);

        /// <summary>
        /// 关闭当前页面，返回上一页面或多级页面
        /// </summary>
        /// <param name="success"></param>
        /// <param name="fail"></param>
        /// <param name="complete"></param>
        public abstract void NavigateBack(Action success, Action fail, Action complete);
    }
}